#include <stdio.h>
#include <stdlib.h>

#define MAXSIZE 1000

typedef struct SNode *Stack;
struct SNode{
    int data[MAXSIZE];
    int Top;
};


// Create an empty stack the largest length of which is MAXSIZE.
Stack CreateStack();

// Judge whether stack S is full or not.
int StackFull(Stack S);

// void Push(Stack S, ElementType item);
// Push element item into the stack.
void Push(Stack S, int item);

// Judge whether Stack S is empty or not.
int StackEmpty(Stack S);

// ElementType Pop(Stack S);
// Delete and return the top element of stack.
int Pop(Stack S);

// void ShowList(Stack S);

Stack CreateStack(){
    Stack S = (Stack) malloc(sizeof(struct SNode *));
    S->Top = -1;
    return S;
}

int StackFull(Stack S){
    if(S->Top == MAXSIZE - 1)
        return 1;
    else
        return 0;
}

void Push(Stack S, int item){
    if(S->Top == MAXSIZE - 1){
        return;
    }
    else{
        S->data[++(S->Top)] = item;
    }
}

int StackEmpty(Stack S){
    if(S->Top == -1)
        return 1;
    else
        return 0;
}

int Pop(Stack S){
    if(S->Top == -1){
        return NULL;
    }
    else{
        return S->data[(S->Top)--];
    }
}

